package com.suning.sawp.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.suning.nsf.istore.rsf.service.intf.RemoteRsfService;
import com.suning.sawp.dto.storeman.JsonResult;
import com.suning.sawp.intf.commodity.BppCommodityService;
import com.suning.sawp.po.commodity.BppCommodityInfo;
import com.suning.sawp.web.exception.MyGsonView;

/**
 * 〈门店咖啡活动〉<br>
 * 〈功能详细描述〉
 *
 * @author 12061748
 * @see [相关类/方法]（可选）
 * @since [产品/模块版本] （可选）
 */
@Controller
@RequestMapping("storeMan")
public class CommdityAndRsfController extends DjBaseController {

    @Autowired
    RemoteRsfService remoteRsfServiceClient;
    
    /**
     * 大聚会商品服务
     */
    @Autowired
    BppCommodityService bppCommodityService;

    /**
     * 
     * 功能描述: 根据门店编码分页查询门店大聚会商品列表<br>
     * 〈功能详细描述〉
     *
     * @param storeCode
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    @RequestMapping(value = "getCommodityInfoList.do", produces = "application/json; charset=utf-8")
    public MyGsonView getCommodityInfoList(Integer start, Integer limit, @RequestParam String storeCode,
            @RequestParam String staffCode) {
        MyGsonView gsonView = createGsonView();
        // 修改服务层接口
        List<BppCommodityInfo> list = bppCommodityService
                .getCommodityInfoList(start, limit, storeCode, staffCode);

        JsonResult jsonResult = new JsonResult(list);
        gsonView.addStaticAttribute("retFlag", jsonResult.getRetFlag());
        gsonView.addStaticAttribute("errorCode", jsonResult.getErrorCode());
        gsonView.addStaticAttribute("errorMessage", jsonResult.getErrorMessage());
        gsonView.addStaticAttribute("data", jsonResult.getData());
        
        return gsonView;
    }

    /**
     * 
     * 功能描述: 通过劵号查询活动接口<br>
     * 〈功能详细描述〉
     *
     * @param storeCode
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    @ResponseBody
    @RequestMapping(value = "queryActivityByCoupon.do", produces = "application/json; charset=utf-8")
    public String queryActivityByCoupon(@RequestParam String ticketNum, @RequestParam String staffCode) {
        return remoteRsfServiceClient.queryCoupons(ticketNum, staffCode);
    }

    /**
     * 
     * 功能描述: 确认领取咖啡<br>
     * 〈功能详细描述〉
     *
     * @param storeCode
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    @ResponseBody
    @RequestMapping(value = "useCoupons.do", produces = "application/json; charset=utf-8")
    public String confirmCoffeeOrder(@RequestParam String ticketNum, @RequestParam String staffCode) {
        return remoteRsfServiceClient.useCoupons(ticketNum, staffCode);
    }
}
